package com.huawei.appgallery.forum.section.card;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import com.huawei.appgallery.forum.base.card.ForumCard;
import com.huawei.appgallery.forum.section.bean.ForumSectionEnterCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.fastengine.fastview.download.utils.PackageUtils;
import com.huawei.hms.support.api.entity.hwid.HwIDConstant.ACTION;
import o.azb;
import o.bqx;
import o.bqy;
import o.brd;
import o.cab.c;
import o.cab.e;
import o.cab.j;
import o.ces;
import o.cet;
import o.ceu;
import o.cgy;
import o.cgz;
import o.eqp;
import o.evx;

public class ForumSectionEnterCard extends ForumCard {
    private boolean ˊ;
    private View ˋ;
    private ForumSectionEnterCardBean ˎ;
    private View ॱ;

    class a implements ces {
        final /* synthetic */ ForumSectionEnterCard ˏ;

        private a(ForumSectionEnterCard forumSectionEnterCard) {
            this.ˏ = forumSectionEnterCard;
        }

        public void onResult(int i) {
            bqx.ˊ("ForumSectionEnterCard", "Restore result=" + i);
            switch (i) {
                case 2000:
                    brd.ॱ.ˏ("action_restore_result", PackageUtils.HWGAMEBOX_PACKAGE_NAME, this.ˏ.ˎ.ॱॱ(), 1);
                    this.ˏ.ˎ(this.ˏ.ʼॱ);
                    return;
                case 2001:
                    brd.ॱ.ˏ("action_restore_install_result", PackageUtils.HWGAMEBOX_PACKAGE_NAME, this.ˏ.ˎ.ॱॱ(), 1);
                    this.ˏ.ˎ(this.ˏ.ʼॱ);
                    return;
                case 2002:
                    this.ˏ.ˎ(this.ˏ.ʼॱ);
                    return;
                case 2101:
                    brd.ॱ.ˏ("action_restore_result", PackageUtils.HWGAMEBOX_PACKAGE_NAME, this.ˏ.ˎ.ॱॱ(), 0);
                    return;
                case 2102:
                case 2103:
                    brd.ॱ.ˏ("action_restore_install_result", PackageUtils.HWGAMEBOX_PACKAGE_NAME, this.ˏ.ˎ.ॱॱ(), 0);
                    return;
                case 2300:
                    brd.ॱ.ˏ("action_restore_confirm", PackageUtils.HWGAMEBOX_PACKAGE_NAME, this.ˏ.ˎ.ॱॱ(), 1);
                    return;
                case 2301:
                    brd.ॱ.ˏ("action_restore_confirm_install", PackageUtils.HWGAMEBOX_PACKAGE_NAME, this.ˏ.ˎ.ॱॱ(), 1);
                    return;
                case 2400:
                    brd.ॱ.ˋ("action_restore_start", PackageUtils.HWGAMEBOX_PACKAGE_NAME, this.ˏ.ˎ.ॱॱ());
                    return;
                case 2401:
                    brd.ॱ.ˏ("action_restore_confirm", PackageUtils.HWGAMEBOX_PACKAGE_NAME, this.ˏ.ˎ.ॱॱ(), 0);
                    return;
                case 2403:
                    brd.ॱ.ˋ("action_restore_start_install", PackageUtils.HWGAMEBOX_PACKAGE_NAME, this.ˏ.ˎ.ॱॱ());
                    return;
                case 2404:
                    brd.ॱ.ˏ("action_restore_confirm_install", PackageUtils.HWGAMEBOX_PACKAGE_NAME, this.ˏ.ˎ.ॱॱ(), 0);
                    return;
                default:
                    return;
            }
        }
    }

    public ForumSectionEnterCard(Context context) {
        super(context);
    }

    public void ˎ(boolean z) {
        this.ˊ = z;
    }

    public cgz ˏ(View view) {
        ʽ(view);
        azb.ˏ(view, e.ॱ);
        this.ʿ = (TextView) view.findViewById(e.ˊ);
        this.ʿ.setText(this.ʼॱ.getResources().getString(j.ॱॱ));
        this.ॱ = view.findViewById(e.ˑ);
        TextView textView = (TextView) view.findViewById(e.ˏˎ);
        textView.setText(this.ʼॱ.getResources().getString(j.ʼ));
        this.ˋ = view.findViewById(e.ˊˋ);
        ˎ(this.ʿ, textView);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        int i = 8;
        if (cardBean instanceof ForumSectionEnterCardBean) {
            this.ˎ = (ForumSectionEnterCardBean) cardBean;
            if (TextUtils.isEmpty(this.ˎ.ॱॱ())) {
                this.ॱ.setVisibility(8);
            } else {
                this.ॱ.setVisibility(0);
                this.ॱ.setTag(this.ˎ);
                this.ॱ.setOnClickListener(new evx(this) {
                    final /* synthetic */ ForumSectionEnterCard ˎ;

                    {
                        this.ˎ = r1;
                    }

                    public void ˋ(View view) {
                        this.ˎ.ˎ();
                        if (!eqp.ᐝ() || !"com.huawei.appmarket".equals(this.ˎ.ʼॱ.getPackageName())) {
                            this.ˎ.ˋ().onClick(this.ˎ.ॱ);
                        } else if (this.ˎ.ʼॱ instanceof Activity) {
                            new ceu((Activity) this.ˎ.ʼॱ).ˊ(new cet(PackageUtils.HWGAMEBOX_PACKAGE_NAME, "gamebox", 90001300), new a());
                        } else {
                            this.ˎ.ˋ().onClick(this.ˎ.ॱ);
                        }
                    }
                });
            }
            View view = this.ˋ;
            if (!this.ˊ) {
                i = 0;
            }
            view.setVisibility(i);
        }
    }

    private void ˎ(Context context) {
        if (context != null) {
            try {
                context.startActivity(new Intent(ACTION.HWID_SCHEME_URL, Uri.parse("higame://com.huawei.gamebox?activityName=activityModule|Section@@@section_detail_activity&params={\"params\":[{\"name\":\"Uri\",\"type\":\"String\",\"value\":\"" + this.ˎ.ॱॱ() + "\"}]}&thirdId=4026620")));
            } catch (Exception e) {
                bqx.ˋ("ForumSectionEnterCard", "openForumByGameBox error");
            }
        }
    }

    private void ˎ(TextView textView, TextView textView2) {
        int ॱ = (((azb.ॱ(this.ʼॱ) - (this.ʼॱ.getResources().getDimensionPixelSize(c.ॱ) * 2)) - this.ʼॱ.getResources().getDimensionPixelSize(c.ˊ)) - this.ʼॱ.getResources().getDimensionPixelSize(c.ᐝ)) - this.ʼॱ.getResources().getDimensionPixelSize(c.ॱˊ);
        int i = (int) (((float) ॱ) * 0.6666667f);
        int ˏ = ˏ(textView, textView.getText().toString());
        int i2 = 0;
        if (i > ˏ) {
            i2 = i - ˏ;
        }
        int i3 = ॱ - i;
        ॱ = ˏ(textView2, textView2.getText().toString());
        if (ॱ <= i3 || i2 <= 0) {
            i2 = i3;
            ॱ = i;
        } else {
            int i4 = ॱ - i3;
            if (i4 > i2) {
                i2 += i3;
                ॱ = ˏ;
            } else {
                int i5 = ॱ;
                ॱ = i - i4;
                i2 = i5;
            }
        }
        textView.setWidth(ॱ);
        textView2.setWidth(i2);
    }

    private int ˏ(TextView textView, String str) {
        if (textView == null || cgy.ˎ(str)) {
            return 0;
        }
        return (((int) textView.getPaint().measureText(str)) + textView.getPaddingLeft()) + textView.getPaddingRight();
    }

    private void ˎ() {
        if (this.ˎ != null) {
            brd.ॱ.ˋ(bqy.ˋ().ˎ(this.ʼॱ), bqy.ˋ().ˎ(), this.ˎ.ˊ(), this.ˎ.ॱॱ());
        }
    }
}
